package com.criteria.po;

import java.util.Objects;

public class Person {

    private String name;
    private String gender;
    private String maritalStatus;

    public Person(String name, String gender, String maritalStatus) {
        this.name = name;
        this.gender = gender;
        this.maritalStatus = maritalStatus;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getMaritalStatus() {
        return maritalStatus;
    }

    public void setMaritalStatus(String maritalStatus) {
        this.maritalStatus = maritalStatus;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", gender='" + gender + '\'' +
                ", maritalStatus='" + maritalStatus + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        /*
            如果name字段可能为空，重写Equals请使用"Objects.equals(this.name, person.name)"，否则可能抛NPE
         */
        return name.equals(person.name) && gender.equals(person.gender) && maritalStatus.equals(person.maritalStatus);
    }

    // 重写HashCode()就必须得重写equals()
    @Override
    public int hashCode() {
        return Objects.hash(name, gender, maritalStatus);
    }
}
